package com.ecommerce.dal.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ecommerce.dal.dao.impl.CategoryPhotoDAO;
import com.ecommerce.dal.dao.impl.CompanyPhotoDAO;
import com.ecommerce.dal.dao.impl.ItemPhotoDAO;
import com.ecommerce.dal.entity.CategoryPhoto;
import com.ecommerce.dal.entity.CompanyPhoto;
import com.ecommerce.dal.entity.ItemPhoto;
import com.ecommerce.dal.service.IPhotoManagementService;


@Service("photoManagementService")
public class PhotoManagementService implements IPhotoManagementService {

	@Autowired
	CategoryPhotoDAO categoryPhotoDAO;
	@Autowired
	ItemPhotoDAO itemPhotoDAO;
	@Autowired
	CompanyPhotoDAO companyPhotoDAO;
	
	@Override
	public void saveItemPhoto(ItemPhoto itemPhoto) {
		itemPhotoDAO.save(itemPhoto);
		
	}

	@Override
	public List<ItemPhoto> retrieveItemPhotos(long itemId) {
		return itemPhotoDAO.findByItemId(itemId);
	}

	@Override
	public void saveCompanyPhoto(CompanyPhoto companyPhoto) {
		companyPhotoDAO.save(companyPhoto);
		
	}

	@Override
	public List<CompanyPhoto> retrieveCompanyPhotos(long companyId) {
		return companyPhotoDAO.findByCompanyId(companyId);
	}

	@Override
	public void saveCategoryPhoto(CategoryPhoto categoryPhoto) {
		categoryPhotoDAO.save(categoryPhoto);
		
	}

	@Override
	public List<CategoryPhoto> retrieveCategoryPhotos(long categoryId) {
		return categoryPhotoDAO.findByCategoryId(categoryId);
	}

	@Override
	public void updatePhotoByCompanyId(CompanyPhoto companyPhoto) {
		companyPhotoDAO.update(companyPhoto);
		
	}

	@Override
	public void updatePhotoByCategoryId(CategoryPhoto categoryPhoto) {
		categoryPhotoDAO.update(categoryPhoto);
		
	}

	@Override
	public void updatePhotoByItemId(ItemPhoto itemPhoto) {
		itemPhotoDAO.update(itemPhoto);
		
	}

	@Override
	public void deletePhotoByCompanyId(CompanyPhoto companyPhoto) {
		companyPhotoDAO.delete(companyPhoto);
		
	}

	@Override
	public void deletePhotoByCategoryId(CategoryPhoto categoryPhoto) {
		categoryPhotoDAO.delete(categoryPhoto);
		
	}

	@Override
	public void deletePhotoByItemId(ItemPhoto itemPhoto) {	
		itemPhotoDAO.delete(itemPhoto);
		
	}
	
}
